
#include <mockcpp/mockcpp.hpp>
#include <testngpp/testngpp.hpp>

#include <ListBoxPeople.h>
#include <People.h>

#include <InchFormat.h>
#include <CascadeFormat.h>

#include <RadioButton.h>
#include <Button.h>

USING_MOCKCPP_NS
USING_TESTNGPP_NS

FIXTURE(ListBoxPeopleCommon)
{
	CascadeFormat cascadeFormat;
	InchFormat inchFormat;
	People peoples;
	SETUP()
	{
		PeopleRecord zhangSan = {"San Zhang",Length(61,INCH)};
		PeopleRecord liSi = {"Si Li",Length(67,INCH)};
		PeopleRecord wangWu = {"Wu Wang",Length(93,INCH)};
		peoples.addPeople(zhangSan);
		peoples.addPeople(liSi);
		peoples.addPeople(wangWu);
	}

	TEST(should be able to output data with requirement:default format)
	{
		ListBoxPeople boxCommon(peoples,cascadeFormat);
                ostringstream oss;
                boxCommon.display(oss);
		ASSERT_EQ(oss.str(), string("San Zhang\t5 FEET 1 INCH\nSi Li\t5 FEET 7 INCH\nWu Wang\t7 FEET 9 INCH"));		
	}

	TEST(should be able to output data with requirement:select INCH format)
	{
		ListBoxPeople boxCommon(peoples,cascadeFormat);
		FormatRadioButton radioButton(cascadeFormat);
		PeopleButton button(radioButton);

                ostringstream oss;
		radioButton.onSelected(inchFormat);
		button.onClick();
	
                boxCommon.display(oss);
		ASSERT_EQ(oss.str(), string("San Zhang\t61 INCH\nSi Li\t67 INCH\nWu Wang\t93 INCH"));
	}

};

FIXTURE(ListBoxPeopleSongDynasty)
{
	CascadeFormat cascadeFormat;
	InchFormat inchFormat;
	People peoples;

	SETUP()
	{
		PeopleRecord qinHui = {"Hui Qin",Length(54,INCH)};
		PeopleRecord yueFei = {"Fei Yue",Length(86,INCH)};
		PeopleRecord zhaoGou = {"Gou Zhao",Length(64,INCH)};

		peoples.addPeople(qinHui);
		peoples.addPeople(yueFei);
		peoples.addPeople(zhaoGou);
	}

	TEST(should be able to output data with requirement:default format)
	{
		ListBoxPeople boxCommon(peoples,cascadeFormat);
                ostringstream oss;
	
		boxCommon.display(oss);
		ASSERT_EQ(oss.str(), string("Hui Qin\t4 FEET 6 INCH\nFei Yue\t7 FEET 2 INCH\nGou Zhao\t5 FEET 4 INCH"));		
	}


	TEST(should be able to output data with requirement:select INCH format)
	{
		ListBoxPeople boxCommon(peoples,cascadeFormat);

		FormatRadioButton radioButton(cascadeFormat);
		PeopleButton button(radioButton);
                ostringstream oss;

		radioButton.onSelected(inchFormat);
		button.onClick();
	
		boxCommon.display(oss);
		ASSERT_EQ(oss.str(), string("Hui Qin\t54 INCH\nFei Yue\t86 INCH\nGou Zhao\t64 INCH"));	
	}

};
